const koa = require('koa');
const koaRouter = require('koa-router');
const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
const config = require('./config');
mongoose.connect(`mongodb://${config.dbUser}:${config.dbPassword}@${config.dbHost}:${config.dbPort}/${config.dbCollection}`);

const app = new koa();
const router = koaRouter();
// include router file
global.rootDir = __dirname;

require('./router.js')(router);

app.use(router.routes())
  .use(router.allowedMethods());

app.listen(3000);
